<!DOCTYPE html>
<html lang="en">

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  <title>注册</title>
  <link href="../../assets/css/normalize.css" rel="stylesheet" />
  <link href="../../assets/css/jquery-ui.css" rel="stylesheet" />
  <link href="../../assets/css/jquery.idealforms.min.css" rel="stylesheet" media="screen" />
  <style type="text/css">
    body {
      font: normal 15px/1.5 Arial, Helvetica, Free Sans, sans-serif;
      color: #222;
      background: url(pattern.png);
      overflow-y: scroll;
      padding: 60px 0 0 0;
    }

    #my-form {
      width: 755px;
      margin: 0 auto;
      border: 1px solid #ccc;
      padding: 3em;
      border-radius: 3px;
      box-shadow: 0 0 2px rgba(0, 0, 0, .2);
    }

    #comments {
      width: 350px;
      height: 100px;
    }
  </style>
</head>

<body>
  <div class="row">

    <div class="eightcol last">
        <div id="my-form">
          <section name="注册用户账号">
            <div><label>用户名:</label><input id="uname" name="bname" type="text" placeholder="*" required /></div>
            <div><label>手机:</label><input id="uphone" name="phone" type="text" placeholder="*" required /></div>
            <div><label>密码:</label><input id="pass" name="pw" type="password" placeholder="*" required /></div>
          </section>

          <div>
            <hr />
          </div>
          <div>
            <button  id="submit">提交</button>
            <button id="reset" type="button">重置</button>
          </div>
        </div>
    </div>
  </div>
  <script src="../../assets/js/jquery-1.8.2.min.js"></script>
  <script src="../../assets/js/jquery-ui.min.js"></script>
  <script src="../../assets/js/jquery.idealforms.js"></script>
  <script>
    var options = {
      inputs: {

      }

    };

    var $myform = $('#my-form').idealforms(options).data('idealforms');

    $('#reset').click(function () {
      $myform.reset().fresh().focusFirst()
    });

    $myform.focusFirst();
  </script>
  <script>
        $('#submit').click(function () { 
        var uname = $('#uname').val();
        var uphone = $('#uphone').val();
        var pass = $('#pass').val();
        console.log('object', uname,uphone,pass);
        $.ajax({
            type: 'get',
            // dataType: 'jsonp',
            // jsonp: 'callback',
            // headers: 'Access-Control-Allow-Origin',
            url: 'http://localhost/dancer/public/json/user/reg',
            data: {
                uphone: uphone,
                upassword: pass,
                uname: uname
            },
            async: false,
            success: function (data) { 
                console.log('data', typeof(data));
                console.log('data', data);
                var json = JSON.parse(data);
                // $('#box').append(data);
                if(json!=null){
                    alert('register successful');
                    location.href = './index.html';
                }else{
                    alert('phoneNumber or password incorrect');
                }
             }
        })

    })
  </script>
  <div style="text-align:center;">

  </div>
</body>

</html>s